Package org.apache.clerezza.rdf.core

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



  private Lock getPartialReadLock(int startPos) {
    ArrayList<Lock> resultList = new ArrayList<Lock>();
    for (int i = startPos; i < baseTripleCollections.length; i++) {
      TripleCollection tripleCollection = baseTripleCollections[i];
      if (tripleCollection instanceof LockableMGraph) {
        final Lock lock = ((LockableMGraph) tripleCollection).getLock().readLock();
        resultList.add(lock);
      }
    }
View Full Code Here


*/
public class RdfListTest {

  @Test
  public void listCreationAndAccess() {
    TripleCollection tc = new SimpleMGraph();
    List<Resource> list = new RdfList(new UriRef("http://example.org/mytest"), tc);
    assertEquals(0, list.size());
    list.add(new PlainLiteralImpl("hello"));
    list.add(new PlainLiteralImpl("world"));
    assertEquals(new PlainLiteralImpl("hello"), list.get(0));
    assertEquals(new PlainLiteralImpl("world"), list.get(1));
    assertEquals(2, list.size());
    list.add(new PlainLiteralImpl("welcome"));
    assertEquals(3, list.size());
    assertEquals(new PlainLiteralImpl("welcome"), list.get(2));
    list.add(1, new PlainLiteralImpl("interesting"));
    assertEquals(4, list.size());
    assertEquals(new PlainLiteralImpl("interesting"), list.get(1));
    assertEquals(new PlainLiteralImpl("world"), list.get(2));
    assertEquals(new PlainLiteralImpl("welcome"), list.get(3));
    list.add(0, new PlainLiteralImpl("start"));
    assertEquals(5, list.size());
    assertEquals(new PlainLiteralImpl("hello"), list.get(1));
    assertEquals(new PlainLiteralImpl("interesting"), list.get(2));
    List<Resource> list2 = new RdfList(new UriRef("http://example.org/mytest"), tc);
    assertEquals(5, list2.size());
    assertEquals(new PlainLiteralImpl("hello"), list2.get(1));
    assertEquals(new PlainLiteralImpl("interesting"), list2.get(2));
    list2.remove(2);
    assertEquals(4, list2.size());
    assertEquals(new PlainLiteralImpl("hello"), list2.get(1));
    assertEquals(new PlainLiteralImpl("world"), list2.get(2));
    while (list2.size() > 0) {
      list2.remove(0);
    }
    assertEquals(1, tc.size()); //list = rdf:nil statement
    list2.add(0, new PlainLiteralImpl("restart"));
    list2.add(1, new PlainLiteralImpl("over"));
    assertEquals(2, list2.size());
    list2.add(new PlainLiteralImpl("2"));
    list2.add(new PlainLiteralImpl("3"));
View Full Code Here

    assertEquals(new PlainLiteralImpl("3"), list2.get(3));
  }

    @Test
  public void listCreationAndAccess2() {
    TripleCollection tc = new SimpleMGraph();
    List<Resource> list = new RdfList(new UriRef("http://example.org/mytest"), tc);
    assertEquals(0, list.size());
    list.add(0,new PlainLiteralImpl("world"));
        list = new RdfList(new UriRef("http://example.org/mytest"), tc);
        list.add(0,new PlainLiteralImpl("beautifuly"));
View Full Code Here

        assertEquals(new PlainLiteralImpl("world"), list.get(2));
    }

    @Test
  public void listCreationAndAccess3() {
    TripleCollection tc = new SimpleMGraph();
    List<Resource> list = new RdfList(new UriRef("http://example.org/mytest"), tc);
    assertEquals(0, list.size());
        BNode node0 = new BNode() {};
        BNode node1 = new BNode() {};
        BNode node2 = new BNode() {};
View Full Code Here

        assertEquals(node2, list.get(2));
    }

  @Test
  public void secondButLastElementAccessTest() {
    TripleCollection tc = new SimpleMGraph();
    List<Resource> list = new RdfList(new UriRef("http://example.org/mytest2"), tc);
    list.add(new PlainLiteralImpl("hello"));
    list.add(new PlainLiteralImpl("world"));
    list.remove(1);
    assertEquals(1, list.size());
View Full Code Here

    assertEquals(1, list.size());
  }

  @Test
  public void cleanGraphAfterRemoval() {
    TripleCollection tc = new SimpleMGraph();
    List<Resource> list = new RdfList(new UriRef("http://example.org/mytest"), tc);
    list.add(new PlainLiteralImpl("hello"));
    list.add(new PlainLiteralImpl("world"));
    list.remove(1);
    Assert.assertEquals(2, tc.size());

  }
View Full Code Here

  }

  @Test
  public void findContainingListNodesAndfindContainingListsTest() {
    TripleCollection tc = new SimpleMGraph();
    GraphNode listA = new GraphNode(new UriRef("http:///listA"), tc);
    GraphNode listB = new GraphNode(new UriRef("http:///listB"), tc);
    BNode element1 = new BNode();
    BNode element2 = new BNode();
    BNode element3 = new BNode();
View Full Code Here

      Iterator<UriRef> tcUriRefs = tripleCollections.iterator();
      while (tcUriRefs.hasNext()) {
        UriRef tcUri = tcUriRefs.next();
        String fileName = folder + getTcFileName(tcUri, ".nt",
            fileNameCount);
        TripleCollection tripleCollection = tcManager.getTriples(tcUri);
        archive(compressedTcs, tripleCollection, fileName);
        if (tripleCollection instanceof MGraph) {
          backupContents.add(new TripleImpl(tcUri, RDF.type,
              BACKUP.MGraph));
        } else {
View Full Code Here

  public void testCustomPermissions() {
    UriRef graphUri = new UriRef("http://example.org/custom");
    TcManager.getInstance().getTcAccessController().setRequiredReadPermissionStrings(graphUri,
        Collections.singletonList("(java.io.FilePermission \"/etc\" \"write\")"));
    //new FilePermission("/etc", "write").toString()));
    TripleCollection ag = TcManager.getInstance().getTriples(new UriRef("urn:x-localinstance:/graph-access.graph"));
    System.out.print(ag.toString());
    TcManager.getInstance().getMGraph(graphUri);
  }
View Full Code Here

  public void testCustomPermissionsIncorrect() {
    UriRef graphUri = new UriRef("http://example.org/custom");
    TcManager.getInstance().getTcAccessController().setRequiredReadPermissionStrings(graphUri,
        Collections.singletonList("(java.io.FilePermission \"/etc\" \"write\")"));
    //new FilePermission("/etc", "write").toString()));
    TripleCollection ag = TcManager.getInstance().getTriples(new UriRef("urn:x-localinstance:/graph-access.graph"));
    System.out.print(ag.toString());
    TcManager.getInstance().createMGraph(graphUri);
  }
View Full Code Here

TOP

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

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.