Revision 50852
Added by Alessia Bardi over 6 years ago
modules/dnet-parthenos-publisher/trunk/test/main/java/eu/dnetlib/parthenos/virtuoso/VirtuosoTest.java | ||
---|---|---|
5 | 5 |
|
6 | 6 |
import org.apache.jena.graph.NodeFactory; |
7 | 7 |
import org.apache.jena.graph.Triple; |
8 |
import org.apache.jena.query.Query; |
|
9 |
import org.apache.jena.query.QueryExecutionFactory; |
|
10 |
import org.apache.jena.query.QueryFactory; |
|
11 |
import org.apache.jena.query.ResultSet; |
|
8 |
import org.apache.jena.query.*; |
|
12 | 9 |
import org.apache.jena.rdf.model.Model; |
10 |
import org.apache.jena.rdf.model.ResIterator; |
|
13 | 11 |
import org.apache.jena.rdf.model.Resource; |
14 | 12 |
import org.apache.jena.rdf.model.ResourceFactory; |
13 |
import org.apache.jena.riot.RDFDataMgr; |
|
14 |
import org.apache.jena.riot.RDFFormat; |
|
15 | 15 |
import org.apache.jena.sparql.engine.http.QueryEngineHTTP; |
16 | 16 |
import org.apache.jena.util.iterator.ExtendedIterator; |
17 | 17 |
import org.junit.Assert; |
... | ... | |
153 | 153 |
long size = md.size(); |
154 | 154 |
System.out.println("==Inserted " + size + "triples=="); |
155 | 155 |
|
156 |
// System.out.println("*************RDF/XML*************"); |
|
157 |
// md.write(System.out, "RDF/XML"); |
|
158 |
|
|
159 |
// System.out.println("*************RDF/XML-ABBREV*************"); |
|
160 |
// md.write(System.out, "RDF/XML-ABBREV"); |
|
161 |
|
|
162 |
// System.out.println("*************Default language*************"); |
|
163 |
// md.write(System.out); |
|
164 |
|
|
165 |
md.write(System.out, "RDF/XML"); |
|
166 |
|
|
167 | 156 |
VirtGraph graph = new VirtGraph(testGraph, connectionString, testUser, testPwd); |
168 | 157 |
assertNotNull(graph); |
169 | 158 |
Assert.assertFalse(graph.isEmpty()); |
... | ... | |
171 | 160 |
graph.clear(); |
172 | 161 |
} |
173 | 162 |
|
163 |
@Test |
|
164 |
public void testFeedAndDump() { |
|
165 |
Model md = VirtModel.openDatabaseModel("obj1", connectionString, testUser, testPwd); |
|
166 |
md.read(getResourceAsStream("eu/dnetlib/parthenos/virtuoso/test.rdf"), defaultURIBaseURl); |
|
167 |
md.close(); |
|
168 |
|
|
169 |
Model md2 = VirtModel.openDatabaseModel("obj1", connectionString, testUser, testPwd); |
|
170 |
final ResIterator resIterator = md2.listSubjects(); |
|
171 |
while(resIterator.hasNext()){ |
|
172 |
Resource r = resIterator.nextResource(); |
|
173 |
System.out.println(r.getURI()+"*************"); |
|
174 |
Dataset d = RDFDataMgr.loadDataset(r.getURI()); |
|
175 |
RDFDataMgr.write(System.out, d, RDFFormat.RDFXML_PLAIN); |
|
176 |
System.out.println("**********************"); |
|
177 |
} |
|
178 |
System.out.println("END"); |
|
179 |
md2.removeAll(); |
|
180 |
md2.close(); |
|
181 |
|
|
182 |
} |
|
183 |
|
|
174 | 184 |
/* |
175 | 185 |
If we want to be able to update, we need to store the triples in different named graph. This way we can delete the old triples and add the new ones. |
176 | 186 |
And then we can add triples about the graph (e.g. provenance, last update time, whatever) in another named graph (e.g. 'provenance'), |
Also available in: Unified diff
Updated test