Search in sources :

Example 1 with ContentAssembler

use of org.apache.jena.assembler.assemblers.ContentAssembler in project jena by apache.

the class TestContentAssembler method testContent.

public void testContent() {
    Assembler a = new ContentAssembler();
    Content c = (Content) a.open(resourceInModel("x rdf:type ja:Content"));
    assertNotNull(c);
    Model m = ModelFactory.createDefaultModel();
    c.fill(m);
    assertEquals(0, m.size());
}
Also used : ContentAssembler(org.apache.jena.assembler.assemblers.ContentAssembler) ContentAssembler(org.apache.jena.assembler.assemblers.ContentAssembler)

Example 2 with ContentAssembler

use of org.apache.jena.assembler.assemblers.ContentAssembler in project jena by apache.

the class TestContentAssembler method testMultipleLiteralsWorks.

public void testMultipleLiteralsWorks() {
    Assembler a = new ContentAssembler();
    String A = "<eh:/A> a <eh:/Type>.".replaceAll(" ", "\\\\s");
    String B = "<eh:/Type> a rdfs:Class.".replaceAll(" ", "\\\\s");
    Resource root = resourceInModel("x rdf:type ja:Content; x rdf:type ja:LiteralContent; x ja:literalContent '" + A + "'; x ja:literalContent '" + B + "'");
    Content C = (Content) a.open(root);
    assertIsoModels(model("Type rdf:type rdfs:Class; A rdf:type Type"), C.fill(model("")));
}
Also used : ContentAssembler(org.apache.jena.assembler.assemblers.ContentAssembler) ContentAssembler(org.apache.jena.assembler.assemblers.ContentAssembler)

Example 3 with ContentAssembler

use of org.apache.jena.assembler.assemblers.ContentAssembler in project jena by apache.

the class TestContentAssembler method testSingleContentQuotation.

public void testSingleContentQuotation() {
    Assembler a = new ContentAssembler();
    Resource root = resourceInModel("c rdf:type ja:Content; c rdf:type ja:QuotedContent; c ja:quotedContent x; x P A; x Q B");
    Content c = (Content) a.open(root);
    assertIsoModels(model("x P A; x Q B"), c.fill(model("")));
}
Also used : ContentAssembler(org.apache.jena.assembler.assemblers.ContentAssembler) ContentAssembler(org.apache.jena.assembler.assemblers.ContentAssembler)

Example 4 with ContentAssembler

use of org.apache.jena.assembler.assemblers.ContentAssembler in project jena by apache.

the class TestContentAssembler method testRDFXMLContent.

public void testRDFXMLContent() {
    Assembler a = new ContentAssembler();
    String Stuff = "<owl:Class></owl:Class>".replaceAll(" ", "\\\\s");
    Resource root = resourceInModel("x rdf:type ja:Content; x rdf:type ja:LiteralContent; x ja:literalContent '" + Stuff + "'; x ja:contentEncoding 'RDF/XML'");
    Content c = (Content) a.open(root);
    assertIsoModels(model("_x rdf:type owl:Class"), c.fill(model("")));
}
Also used : ContentAssembler(org.apache.jena.assembler.assemblers.ContentAssembler) ContentAssembler(org.apache.jena.assembler.assemblers.ContentAssembler)

Example 5 with ContentAssembler

use of org.apache.jena.assembler.assemblers.ContentAssembler in project jena by apache.

the class TestContentAssembler method testContentTrapsBadObjects.

private void testContentTrapsBadObjects(String property, String value) {
    Assembler a = new ContentAssembler();
    Resource root = resourceInModel("x rdf:type ja:Content; x <property> <value>".replaceAll("<property>", property).replaceAll("<value>", value));
    try {
        a.open(root);
        fail("should trap bad content resource");
    } catch (BadObjectException e) {
        assertEquals(resource("x"), e.getRoot());
        assertEquals(rdfNode(empty, value), e.getObject());
    }
}
Also used : ContentAssembler(org.apache.jena.assembler.assemblers.ContentAssembler) ContentAssembler(org.apache.jena.assembler.assemblers.ContentAssembler)

Aggregations

ContentAssembler (org.apache.jena.assembler.assemblers.ContentAssembler)16 UnknownEncodingException (org.apache.jena.assembler.exceptions.UnknownEncodingException)1 Model (org.apache.jena.rdf.model.Model)1 Resource (org.apache.jena.rdf.model.Resource)1