testImport(cfg);
}
private void testImport(KiWiLoaderConfiguration c) throws RDFParseException, IOException, RDFHandlerException {
KiWiHandler handler;
if(store.getPersistence().getDialect() instanceof PostgreSQLDialect) {
handler = new KiWiPostgresHandler(store, c);
} else if(store.getPersistence().getDialect() instanceof MySQLDialect) {
handler = new KiWiMySQLHandler(store, c);
} else {
handler = new KiWiHandler(store, c);
}
try {
// bulk import
long start = System.currentTimeMillis();
RDFParser parser = Rio.createParser(RDFFormat.RDFXML);
parser.setRDFHandler(handler);
parser.parse(this.getClass().getResourceAsStream("demo-data.foaf"),"");
logger.info("bulk import in {} ms", System.currentTimeMillis() - start);
// check presence of data
try {
RepositoryConnection con = repository.getConnection();
try {
con.begin();
Assert.assertTrue(con.hasStatement(null,null,null,true));
con.commit();
} catch(RepositoryException ex) {
con.rollback();
} finally {
con.close();
}
} catch(RepositoryException ex) {
ex.printStackTrace(); // TODO: handle error
}
} finally {
handler.shutdown();
}
}