Examples of ParsingProvider


Examples of org.apache.clerezza.rdf.core.serializedform.ParsingProvider

  /*
   * comparing result from nt and turtle parsing,
   */
  @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

Examples of org.apache.clerezza.rdf.core.serializedform.ParsingProvider

  /*
   * comparing result from nt and rdf/xml parsing,
   */
  @Test
  public void testRdfXmlParser() {
    ParsingProvider provider = new JenaParserProvider();
    InputStream nTriplesIn = getClass().getResourceAsStream("test-04.nt");
    InputStream rdfIn = getClass().getResourceAsStream("test-04.rdf");
    Graph graphFromNTriples = parse(provider, nTriplesIn, "text/rdf+nt", null);
    Graph graphFromTurtle = parse(provider, rdfIn, "application/rdf+xml", null);
    Assert.assertEquals(graphFromNTriples, graphFromTurtle);
View Full Code Here

Examples of org.apache.clerezza.rdf.core.serializedform.ParsingProvider

    Assert.assertEquals(graphFromNTriples, graphFromTurtle);
  }
 
  @Test
  public void testTurtleParserWithArgument() {
    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;charset=UTF-", null);
    Assert.assertEquals(graphFromNTriples, graphFromTurtle);
View Full Code Here

Examples of org.apache.clerezza.rdf.core.serializedform.ParsingProvider

*/
public class RdfJsonParserProviderTest {

  @Test
  public void testParsingOfObjectBNode() {
    ParsingProvider provider = new RdfJsonParsingProvider();
    InputStream jsonIn = getClass().getResourceAsStream("test-object-bnode.json");
    MGraph parsedMGraph = new SimpleMGraph();
    provider.parse(parsedMGraph, jsonIn, "application/rdf+json", null);
    Assert.assertEquals(parsedMGraph.size(), 1);
    Iterator<Triple> triples = parsedMGraph.filter(new UriRef("http://example.org/node1"),
        new UriRef("http://example.org/prop1"), null);
    Assert.assertTrue(triples.hasNext());
    Assert.assertTrue(triples.next().getObject() instanceof BNode);
View Full Code Here

Examples of org.apache.clerezza.rdf.core.serializedform.ParsingProvider

    Assert.assertTrue(triples.next().getObject() instanceof BNode);
  }

  @Test
  public void testParsingOfSubjectBNode() {
    ParsingProvider provider = new RdfJsonParsingProvider();
    InputStream jsonIn = getClass().getResourceAsStream("test-subject-bnode.json");
    MGraph parsedMGraph = new SimpleMGraph();
    provider.parse(parsedMGraph, jsonIn, "application/rdf+json", null);
    Assert.assertEquals(3, parsedMGraph.size());
    Iterator<Triple> triples = parsedMGraph.filter(null, new UriRef("http://example.org/prop1"),
        new UriRef("http://example.org/node1"));
    Assert.assertTrue(triples.hasNext());
    NonLiteral subject = triples.next().getSubject();
View Full Code Here

Examples of org.apache.clerezza.rdf.core.serializedform.ParsingProvider

    Assert.assertFalse(subject.equals(triples.next().getSubject()));
  }

  @Test
  public void testParser() {
    ParsingProvider provider = new RdfJsonParsingProvider();
    InputStream jsonIn = getClass().getResourceAsStream("test.json");
    MGraph deserializedMGraph = new SimpleMGraph();
    provider.parse(deserializedMGraph, jsonIn, "application/rdf+json", null);
    Assert.assertEquals(deserializedMGraph.size(), 6);
    Iterator<Triple> triples = deserializedMGraph.filter(new UriRef("http://base/child1"), null, null);
    while (triples.hasNext()) {
      UriRef uri = triples.next().getPredicate();
      Assert.assertEquals(uri.getUnicodeString(), "http://base/propertyB");
View Full Code Here

Examples of org.apache.clerezza.rdf.core.serializedform.ParsingProvider

    ByteArrayOutputStream serializedGraph = new ByteArrayOutputStream();
    provider.serialize(serializedGraph, mGraph, "application/rdf+json");

//    System.out.println(serializedGraph.toString());

    ParsingProvider parsingProvider = new RdfJsonParsingProvider();
    ByteArrayInputStream jsonIn = new ByteArrayInputStream(serializedGraph.toByteArray());
    MGraph parsedMGraph = new SimpleMGraph();
    parsingProvider.parse(parsedMGraph, jsonIn, "application/rdf+json", null);

    Assert.assertEquals(mGraph.getGraph(), parsedMGraph.getGraph());
  }
View Full Code Here

Examples of org.apache.clerezza.rdf.core.serializedform.ParsingProvider

    SerializingProvider provider = new RdfJsonSerializingProvider();
    ByteArrayOutputStream serializedGraph = new ByteArrayOutputStream();
    provider.serialize(serializedGraph, mGraph, "application/rdf+json");
//        System.out.println(serializedGraph.toString());
    ParsingProvider parsingProvider = new RdfJsonParsingProvider();
    ByteArrayInputStream jsonIn = new ByteArrayInputStream(serializedGraph.toByteArray());
    MGraph parsedMGraph = new SimpleMGraph();
    parsingProvider.parse(parsedMGraph, jsonIn, "application/rdf+json", null);

    Assert.assertEquals(6, parsedMGraph.size());
    Assert.assertEquals(mGraph.getGraph(), parsedMGraph.getGraph());
  }
View Full Code Here

Examples of org.apache.clerezza.rdf.core.serializedform.ParsingProvider

    SerializingProvider provider = new RdfJsonSerializingProvider();
    ByteArrayOutputStream serializedGraph = new ByteArrayOutputStream();
    long start = System.currentTimeMillis();
    provider.serialize(serializedGraph, mGraph, "application/rdf+json");
    System.out.println("Serialized " + mGraph.size() + " Triples in " + (System.currentTimeMillis() - start) + " ms");
        ParsingProvider parsingProvider = new RdfJsonParsingProvider();
        ByteArrayInputStream jsonIn = new ByteArrayInputStream(serializedGraph.toByteArray());
        MGraph parsedMGraph = new SimpleMGraph();
        parsingProvider.parse(parsedMGraph, jsonIn, "application/rdf+json", null);
        Assert.assertEquals(originalSize, parsedMGraph.size());
        sortedTriples = parsedMGraph.toArray(new Triple[parsedMGraph.size()]);
        Arrays.sort(sortedTriples, RdfJsonSerializingProvider.SUBJECT_COMPARATOR);
        Assert.assertEquals(mGraph.getGraph(), parsedMGraph.getGraph());
  }
View Full Code Here

Examples of org.apache.clerezza.rdf.core.serializedform.ParsingProvider

   
    private ClerezzaBackend backend;
    private LDPath<Resource> ldpath;
    @BeforeClass
    public static void readTestData() throws IOException {
        ParsingProvider parser = new JenaParserProvider();
        //NOTE(rw): the new third parameter is the base URI used to resolve relative paths
        graph = new IndexedMGraph();
        InputStream in = ClerezzaBackendTest.class.getClassLoader().getResourceAsStream("testdata.rdf.zip");
        assertNotNull(in);
        ZipInputStream zipIn = new ZipInputStream(new BufferedInputStream(in));
        InputStream uncloseable = new UncloseableStream(zipIn);
        ZipEntry entry;
        while((entry = zipIn.getNextEntry()) != null){
            if(entry.getName().endsWith(".rdf")){
                parser.parse(graph,uncloseable, SupportedFormat.RDF_XML,null);
            }
        }
        assertTrue(graph.size() > 0);
        zipIn.close();
       
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.