Package org.apache.clerezza.rdf.core

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


        orgdata.add(new TripleImpl(kondalor, type, companyType));
        orgdata.add(new TripleImpl(kondalor, name, new PlainLiteralImpl("Kondalor Ges.m.b.H.")));
        orgdata.add(new TripleImpl(tim, worksFor, kondalor));
       
        //now get the union graph
        Graph data = provider.getGraph(UNION_GRAPH_NAME);
        Assert.assertNotNull(data);
        //CLEREZZA-714: getTriples need to correctly return the UnionGraph
        data = (Graph)provider.getTriples(UNION_GRAPH_NAME);
        Assert.assertNotNull(data);
        //NOTE: Jena TDB does not support getSize for the union graph
//        int expectedTripleCount = persons.size()+orgdata.size();
//        Assert.assertEquals("Uniongraph has "+data.size()
//            +" triples (expected "+expectedTripleCount+")",
//            expectedTripleCount, data.size());
        Iterator<Triple> it = data.filter(null, type, companyType);
        Set<UriRef> expected = new HashSet<UriRef>(Arrays.asList(talinor,kondalor));
        while(it.hasNext()){
            NonLiteral subject = it.next().getSubject();
            Assert.assertTrue("Unexpected "+subject, expected.remove(subject));
        }
        Assert.assertTrue("Missing "+expected, expected.isEmpty());

        it = data.filter(null, type, personType);
        expected = new HashSet<UriRef>(Arrays.asList(john,tim));
        while(it.hasNext()){
            NonLiteral subject = it.next().getSubject();
            Assert.assertTrue("Unexpected "+subject, expected.remove(subject));
        }
View Full Code Here


     * Assert union graph on an empty dataset
     */
    @Test
    public void testEmptyUnionGraph(){
        TcProvider provider = getInstance();
        Graph grpah = provider.getGraph(UNION_GRAPH_NAME);
        Assert.assertNotNull(grpah);
    }
View Full Code Here

        orgdata.add(new TripleImpl(kondalor, type, companyType));
        orgdata.add(new TripleImpl(kondalor, name, new PlainLiteralImpl("Kondalor Ges.m.b.H.")));
        orgdata.add(new TripleImpl(tim, worksFor, kondalor));
       
        //now get the union graph
        Graph data = provider.getGraph(UNION_GRAPH_NAME);
        Assert.assertNotNull(data);
        //CLEREZZA-714: getTriples need to correctly return the UnionGraph
        data = (Graph)provider.getTriples(UNION_GRAPH_NAME);
        Assert.assertNotNull(data);
        //NOTE: Jena TDB does not support getSize for the union graph
//        int expectedTripleCount = persons.size()+orgdata.size();
//        Assert.assertEquals("Uniongraph has "+data.size()
//            +" triples (expected "+expectedTripleCount+")",
//            expectedTripleCount, data.size());
        Iterator<Triple> it = data.filter(null, type, companyType);
        Set<UriRef> expected = new HashSet<UriRef>(Arrays.asList(talinor,kondalor));
        while(it.hasNext()){
            NonLiteral subject = it.next().getSubject();
            Assert.assertTrue("Unexpected "+subject, expected.remove(subject));
        }
        Assert.assertTrue("Missing "+expected, expected.isEmpty());

        it = data.filter(null, type, personType);
        expected = new HashSet<UriRef>(Arrays.asList(john,tim));
        while(it.hasNext()){
            NonLiteral subject = it.next().getSubject();
            Assert.assertTrue("Unexpected "+subject, expected.remove(subject));
        }
View Full Code Here

        con.addRequestProperty("Accept", "application/rdf+xml");
        final InputStream inputStream = con.getInputStream();

        //get the singleton instance of Parser
        final Parser parser = Parser.getInstance();
        Graph deserializedGraph = parser.parse(inputStream, "application/rdf+xml");

        mGraph.addAll(deserializedGraph);
        for (GraphChangedListener graphChangedListener : graphChangedListeners) {
            graphChangedListener.graphChanged();
        }
View Full Code Here

        ByteArrayOutputStream serializedGraph = new ByteArrayOutputStream();
        provider.serialize(serializedGraph, mGraph.getGraph(),
                "text/turtle");
        InputStream in = new ByteArrayInputStream(serializedGraph.toByteArray());

        Graph deserializedGraph = parse(in, "TURTLE");
        // due to http://issues.trialox.org/jira/browse/RDF-6 we cannot just
        // check
        // that the two graphs are equals
        Assert.assertEquals(deserializedGraph.size(), mGraph.getGraph().size());
        Assert.assertEquals(deserializedGraph.hashCode(), mGraph.getGraph()
                .hashCode());
        // isomorphism delegated to jena
        JenaGraph jenaGraphFromNTriples = new JenaGraph(deserializedGraph);
        JenaGraph jenaGraphFromTurtle = new JenaGraph(mGraph.getGraph());
        Assert.assertTrue(jenaGraphFromNTriples
View Full Code Here

        ByteArrayOutputStream serializedGraph = new ByteArrayOutputStream();
        provider.serialize(serializedGraph, mGraph.getGraph(),
                "text/turtle;param=test");
        InputStream in = new ByteArrayInputStream(serializedGraph.toByteArray());

        Graph deserializedGraph = parse(in, "TURTLE");
        Assert.assertEquals(mGraph.getGraph(), deserializedGraph);

    }
View Full Code Here

        ByteArrayOutputStream serializedGraph = new ByteArrayOutputStream();
        provider.serialize(serializedGraph, mGraph.getGraph(),
                "application/rdf+xml");
        InputStream in = new ByteArrayInputStream(serializedGraph.toByteArray());

        Graph deserializedGraph = parse(in, "RDF/XML-ABBREV");
        Assert.assertEquals(mGraph.getGraph(), deserializedGraph);
    }
View Full Code Here

        ByteArrayOutputStream serializedGraph = new ByteArrayOutputStream();
        provider.serialize(serializedGraph, mGraph.getGraph(), "text/rdf+nt");
        InputStream in = new ByteArrayInputStream(serializedGraph.toByteArray());

        Graph deserializedGraph = parse(in, "N-TRIPLE");
        Assert.assertEquals(mGraph.getGraph(), deserializedGraph);
    }
View Full Code Here

        ByteArrayOutputStream serializedGraph = new ByteArrayOutputStream();
        provider.serialize(serializedGraph, mGraph.getGraph(), "text/rdf+n3");
        InputStream in = new ByteArrayInputStream(serializedGraph.toByteArray());

        Graph deserializedGraph = parse(in, "N3");
        Assert.assertEquals(mGraph.getGraph(), deserializedGraph);
    }
View Full Code Here

    @Test
    public void testTurtleParser() {
        ParsingProvider provider = new JenaParserProvider();
        InputStream nTriplesIn = getClass().getResourceAsStream("test-04.nt");
        InputStream turtleIn = getClass().getResourceAsStream("test-04.ttl");
        Graph graphFromNTriples = parse(provider, nTriplesIn, "text/rdf+nt", null);
        Graph graphFromTurtle = parse(provider, turtleIn, "text/turtle", null);
        Assert.assertEquals(graphFromNTriples, graphFromTurtle);
    }
View Full Code Here

TOP

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

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.