Refine search
@Test public void dataset_03() { Dataset ds = createDataset(); ds.setDefaultModel(model2); assertTrue(model2.isIsomorphicWith(ds.getDefaultModel())); }
@Test public void testEquality() throws Exception { Model ttl = ModelFactory.createDefaultModel().read(getTTLInput(), NS, "TTL"); Model rdf = ModelFactory.createDefaultModel().read(getRDFInput(), NS, "RDF/XML-ABBREV"); assertTrue(ttl.isIsomorphicWith(rdf)); assertTrue(rdf.isIsomorphicWith(ttl)); }
@Test public void testEquality() throws Exception { Model ttl = ModelFactory.createDefaultModel().read(getTTLInput(), NS, "TTL"); Model rdf = ModelFactory.createDefaultModel().read(getRDFInput(), NS, "RDF/XML-ABBREV"); assertTrue(ttl.isIsomorphicWith(rdf)); assertTrue(rdf.isIsomorphicWith(ttl)); }
/** * Test that we do not use an "" prefix in @Context. */ @Test public final void noEmptyPrefixInContext() { String ns = "http://www.a.com/foo/"; Model m = simpleModel(ns); m.setNsPrefix("", ns); String jsonld = toString(m, RDFFormat.JSONLD_COMPACT_PRETTY, null); assertFalse(jsonld.contains("\"\"")); Model m2 = parse(jsonld); assertTrue(m2.isIsomorphicWith(m)); }
@Test public void rdfjson_read_simple_plainliteral_object() { String s = "{ \"http://example.org/subject\" : { \"http://example.org/predicate\" : [ { \"type\" : \"literal\" , \"value\" : \"some text\" } ] } }" ; String s2 = "<http://example.org/subject> <http://example.org/predicate> \"some text\" ." ; assertEquals(1, parseCount(s)) ; Model m = parseToModelRdfJson(s) ; Model m2 = parseToModelNTriples(s2) ; assertTrue(m.isIsomorphicWith(m2)) ; }
@Test public void rdfjson_read_simple_typedliteral_object() { String s = "{ \"http://example.org/subject\" : { \"http://example.org/predicate\" : [ { \"type\" : \"literal\" , \"value\" : \"some text\", \"datatype\" : \"http://example.org/datatype\" } ] } }" ; String s2 = "<http://example.org/subject> <http://example.org/predicate> \"some text\"^^<http://example.org/datatype> ." ; assertEquals(1, parseCount(s)) ; Model m = parseToModelRdfJson(s) ; Model m2 = parseToModelNTriples(s2) ; assertTrue(m.isIsomorphicWith(m2)) ; }
@Test public void rdfjson_read_predicatelist() { String s = "{ \"http://example.org/subject\" : { \"http://example.org/predicate\" : [ { \"type\" : \"uri\" , \"value\" : \"http://example.org/object\" } ] , \"http://example.org/predicate2\" : [ { \"type\" : \"uri\" , \"value\" : \"http://example.org/object\" } ] } }" ; String s2 = "<http://example.org/subject> <http://example.org/predicate> <http://example.org/object> .\n" + "<http://example.org/subject> <http://example.org/predicate2> <http://example.org/object> ." ; assertEquals(2, parseCount(s)) ; Model m = parseToModelRdfJson(s) ; Model m2 = parseToModelNTriples(s2) ; assertTrue(m.isIsomorphicWith(m2)) ; }
@Test public void rdfjson_read_subjectlist() { String s = "{ \"http://example.org/subject\" : { \"http://example.org/predicate\" : [ { \"type\" : \"uri\" , \"value\" : \"http://example.org/object\" } ] } , \"http://example.org/subject2\" : { \"http://example.org/predicate\" : [ { \"type\" : \"uri\" , \"value\" : \"http://example.org/object\" } ] } }" ; String s2 = "<http://example.org/subject> <http://example.org/predicate> <http://example.org/object> .\n" + "<http://example.org/subject2> <http://example.org/predicate> <http://example.org/object> ." ; assertEquals(2, parseCount(s)) ; Model m = parseToModelRdfJson(s) ; Model m2 = parseToModelNTriples(s2) ; assertTrue(m.isIsomorphicWith(m2)) ; }
/** * Test the identity transform - RDF/XML to RDF/XML */ @Test public void testRdfcatIdentity() { Model source = ModelFactory.createDefaultModel(); source.read( "file:testing/cmd/rdfcat.xml", "RDF/XML" ); OutputStream so = new ByteArrayOutputStream(); rdfcatFixture rc = new rdfcatFixture( so ); rc.testGo( new String[] {"file:testing/cmd/rdfcat.xml"} ); Model output = asModel( so, "RDF/XML" ); assertTrue( output.isIsomorphicWith( source )); }
@Test public void rdfjson_read_empty_graph() { String s = "{}" ; String s2 = "" ; assertEquals(0, parseCount(s)) ; Model m = parseToModelRdfJson(s) ; Model m2 = parseToModelNTriples(s2) ; assertTrue(m.isIsomorphicWith(m2)) ; }
@Test public void rdfjson_read_objectlist_uris() { String s = "{ \"http://example.org/subject\" : { \"http://example.org/predicate\" : [ { \"type\" : \"uri\" , \"value\" : \"http://example.org/object\" } , { \"type\" : \"uri\" , \"value\" : \"http://example.org/object2\" } ] } }" ; String s2 = "<http://example.org/subject> <http://example.org/predicate> <http://example.org/object> .\n" + "<http://example.org/subject> <http://example.org/predicate> <http://example.org/object2> ." ; assertEquals(2, parseCount(s)) ; Model m = parseToModelRdfJson(s) ; Model m2 = parseToModelNTriples(s2) ; assertTrue(m.isIsomorphicWith(m2)) ; }
@Test public void rdfjson_read_objectlist_literals() { String s = "{ \"http://example.org/subject\" : { \"http://example.org/predicate\" : [ { \"type\" : \"literal\" , \"value\" : \"some text\" } , { \"type\" : \"literal\" , \"value\" : \"more text\" } ] } }" ; String s2 = "<http://example.org/subject> <http://example.org/predicate> \"some text\" .\n" + "<http://example.org/subject> <http://example.org/predicate> \"more text\" ." ; assertEquals(2, parseCount(s)) ; Model m = parseToModelRdfJson(s) ; Model m2 = parseToModelNTriples(s2) ; assertTrue(m.isIsomorphicWith(m2)) ; }
@Test public void rdfjson_read_bnode_identity2() { String s = "{ \"http://example.org/subject\" : { \"http://example.org/predicate\" : [ { \"type\" : \"bnode\" , \"value\" : \"_:id\" } ] , \"http://example.org/predicate2\" : [ { \"type\" : \"bnode\" , \"value\" : \"_:id\" } ] } }" ; String s2 = "<http://example.org/subject> <http://example.org/predicate> _:id ." + "<http://example.org/subject> <http://example.org/predicate2> _:id ." ; assertEquals(2, parseCount(s)) ; Model m = parseToModelRdfJson(s) ; Model m2 = parseToModelNTriples(s2) ; assertTrue(m.isIsomorphicWith(m2)) ; }
@Test public void rdfjson_read_simple_uri_object() { String s = "{ \"http://example.org/subject\" : { \"http://example.org/predicate\" : [ { \"type\" : \"uri\" , \"value\" : \"http://example.org/object\" } ] } }" ; String s2 = "<http://example.org/subject> <http://example.org/predicate> <http://example.org/object> ." ; assertEquals(1, parseCount(s)) ; Model m = parseToModelRdfJson(s) ; Model m2 = parseToModelNTriples(s2) ; assertTrue(m.isIsomorphicWith(m2)) ; }
@Test public void rdfjson_read_simple_bnode_subject() { String s = "{ \"_:id\" : { \"http://example.org/predicate\" : [ { \"type\" : \"uri\" , \"value\" : \"http://example.org/object\" } ] } }" ; String s2 = "_:id <http://example.org/predicate> <http://example.org/object> ." ; assertEquals(1, parseCount(s)) ; Model m = parseToModelRdfJson(s) ; Model m2 = parseToModelNTriples(s2) ; assertTrue(m.isIsomorphicWith(m2)) ; }
@Test public void rdfjson_read_simple_langliteral_object() { String s = "{ \"http://example.org/subject\" : { \"http://example.org/predicate\" : [ { \"type\" : \"literal\" , \"value\" : \"some text\", \"lang\" : \"en-gb\" } ] } }" ; String s2 = "<http://example.org/subject> <http://example.org/predicate> \"some text\"@en-gb ." ; assertEquals(1, parseCount(s)) ; Model m = parseToModelRdfJson(s) ; Model m2 = parseToModelNTriples(s2) ; assertTrue(m.isIsomorphicWith(m2)) ; }
@Test public void rdfjson_read_objectlist_bnodes() { String s = "{ \"http://example.org/subject\" : { \"http://example.org/predicate\" : [ { \"type\" : \"bnode\" , \"value\" : \"_:one\" } , { \"type\" : \"bnode\" , \"value\" : \"_:two\" } ] } }" ; String s2 = "<http://example.org/subject> <http://example.org/predicate> _:a .\n" + "<http://example.org/subject> <http://example.org/predicate> _:b ." ; assertEquals(2, parseCount(s)) ; Model m = parseToModelRdfJson(s) ; Model m2 = parseToModelNTriples(s2) ; assertTrue(m.isIsomorphicWith(m2)) ; }
@Test public void rdfjson_read_objectlist_mixed() { String s = "{ \"http://example.org/subject\" : { \"http://example.org/predicate\" : [ { \"type\" : \"uri\" , \"value\" : \"http://example.org/object\" } , { \"type\" : \"literal\" , \"value\" : \"some text\" } , { \"type\" : \"bnode\" , \"value\" : \"_:id\" } ] } }" ; String s2 = "<http://example.org/subject> <http://example.org/predicate> <http://example.org/object> .\n" + "<http://example.org/subject> <http://example.org/predicate> \"some text\" .\n" + "<http://example.org/subject> <http://example.org/predicate> _:id ." ; assertEquals(3, parseCount(s)) ; Model m = parseToModelRdfJson(s) ; Model m2 = parseToModelNTriples(s2) ; assertTrue(m.isIsomorphicWith(m2)) ; }
/** * Test the basic concatenation */ @Test public void testRdfcatConcat() { Model source = ModelFactory.createDefaultModel(); source.read( "file:testing/cmd/rdfcat.xml", "RDF/XML" ); OutputStream so = new ByteArrayOutputStream(); rdfcatFixture rc = new rdfcatFixture( so ); rc.testGo( new String[] {"file:testing/cmd/rdfcat_1.xml", "file:testing/cmd/rdfcat_2.xml"} ); Model output = asModel( so, "RDF/XML" ); assertTrue( output.isIsomorphicWith( source )); }
@Test public void rdfjson_read_simple_bnode_object() { String s = "{ \"http://example.org/subject\" : { \"http://example.org/predicate\" : [ { \"type\" : \"bnode\" , \"value\" : \"_:id\" } ] } }" ; String s2 = "<http://example.org/subject> <http://example.org/predicate> _:id ." ; assertEquals(1, parseCount(s)) ; Model m = parseToModelRdfJson(s) ; Model m2 = parseToModelNTriples(s2) ; assertTrue(m.isIsomorphicWith(m2)) ; }