01: package org.ontoware.rdf2go;
02:
03: import org.junit.Test;
04: import org.ontoware.aifbcommons.collection.ClosableIterator;
05: import org.ontoware.rdf2go.impl.jena24.ModelFactoryImpl;
06: import org.ontoware.rdf2go.model.Model;
07: import org.ontoware.rdf2go.model.Statement;
08: import org.ontoware.rdf2go.model.node.BlankNode;
09: import org.ontoware.rdf2go.model.node.URI;
10: import org.openrdf.rdf2go.RepositoryModelFactory;
11:
12: public class TestCopyingBlankNodesAcrossImplementations {
13:
14: @Test
15: public void testSesame2Jena() {
16: ModelFactory sesame = new RepositoryModelFactory();
17: Model sesameModel = sesame.createModel();
18: sesameModel.open();
19:
20: ModelFactory jena = new ModelFactoryImpl();
21: Model jenaModel = jena.createModel();
22: jenaModel.open();
23:
24: BlankNode sBnode1 = sesameModel.createBlankNode();
25: BlankNode sBnode2 = sesameModel.createBlankNode();
26: URI hasId = sesameModel.createURI("urn:test:hasId");
27: URI p = sesameModel.createURI("urn:test:p");
28:
29: sesameModel.addStatement(sBnode1, hasId, "1");
30: sesameModel.addStatement(sBnode2, hasId, "2");
31: sesameModel.addStatement(sBnode1, p, sBnode2);
32:
33: ClosableIterator<Statement> it = sesameModel.iterator();
34: jenaModel.addAll(it);
35: it.close();
36:
37: jenaModel.dump();
38: }
39:
40: @Test
41: public void testJena2Sesame() {
42: ModelFactory sesame = new RepositoryModelFactory();
43: Model sesameModel = sesame.createModel();
44: sesameModel.open();
45:
46: ModelFactory jena = new ModelFactoryImpl();
47: Model jenaModel = jena.createModel();
48: jenaModel.open();
49:
50: BlankNode sBnode1 = jenaModel.createBlankNode();
51: BlankNode sBnode2 = jenaModel.createBlankNode();
52: URI hasId = jenaModel.createURI("urn:test:hasId");
53: URI p = jenaModel.createURI("urn:test:p");
54:
55: jenaModel.addStatement(sBnode1, hasId, "1");
56: jenaModel.addStatement(sBnode2, hasId, "2");
57: jenaModel.addStatement(sBnode1, p, sBnode2);
58:
59: ClosableIterator<Statement> it = jenaModel.iterator();
60: sesameModel.addAll(it);
61: it.close();
62:
63: sesameModel.dump();
64: }
65:
66: }
|