use of org.apache.rya.helper.TestFile in project incubator-rya by apache.
the class AccumuloRyaSailFactoryLoadFilesIT method testFileLoading.
@Test
public void testFileLoading() throws Exception {
log.info("Starting file loading test...");
final String query = "SELECT * WHERE { ?s ?p ?o . FILTER(?p != <" + RdfCloudTripleStoreConstants.RTS_VERSION_PREDICATE + ">) }";
final String deleteQuery = "DELETE WHERE { ?s ?p ?o . }";
for (final TestFile testFile : TestFileUtils.TEST_FILES) {
final String testFilePath = testFile.getPath();
final RDFFormat rdfFormat = RdfFormatUtils.forFileName(testFilePath, null);
log.info("Loading file \"" + testFilePath + "\" with RDFFormat: " + rdfFormat.getName());
try (final InputStream rdfContent = getClass().getResourceAsStream(testFilePath)) {
addTriples(ryaRepository, rdfContent, rdfFormat);
}
SailRepositoryConnection queryConn = null;
try {
log.info("Querying for triples in the repository from the " + rdfFormat.getName() + " file.");
queryConn = ryaRepository.getConnection();
final int count = performTupleQuery(query, queryConn);
assertEquals("Expected number of triples not found in: " + testFilePath, testFile.getExpectedCount(), count);
} finally {
closeQuietly(queryConn);
}
SailRepositoryConnection deleteConn = null;
try {
log.info("Deleting triples in the repository from the " + rdfFormat.getName() + " file.");
deleteConn = ryaRepository.getConnection();
final Update update = deleteConn.prepareUpdate(QueryLanguage.SPARQL, deleteQuery);
update.execute();
} finally {
closeQuietly(deleteConn);
}
}
log.info("File loading test finished.");
}
use of org.apache.rya.helper.TestFile in project incubator-rya by apache.
the class MongoDbRyaSailFactoryLoadFilesIT method testFileLoading.
@Test
public void testFileLoading() throws Exception {
log.info("Starting file loading test...");
final String query = "SELECT * WHERE { ?s ?p ?o . }";
final String deleteQuery = "DELETE WHERE { ?s ?p ?o . }";
for (final TestFile testFile : TestFileUtils.TEST_FILES) {
final String testFilePath = testFile.getPath();
final RDFFormat rdfFormat = RdfFormatUtils.forFileName(testFilePath, null);
log.info("Loading file \"" + testFilePath + "\" with RDFFormat: " + rdfFormat.getName());
try (final InputStream rdfContent = getClass().getResourceAsStream(testFilePath)) {
addTriples(ryaRepository, rdfContent, rdfFormat);
}
SailRepositoryConnection queryConn = null;
try {
log.info("Querying for triples in the repository from the " + rdfFormat.getName() + " file.");
queryConn = ryaRepository.getConnection();
final int count = performTupleQuery(query, queryConn);
assertEquals("Expected number of triples not found in: " + testFilePath, testFile.getExpectedCount(), count);
} finally {
closeQuietly(queryConn);
}
SailRepositoryConnection deleteConn = null;
try {
log.info("Deleting triples in the repository from the " + rdfFormat.getName() + " file.");
deleteConn = ryaRepository.getConnection();
final Update update = deleteConn.prepareUpdate(QueryLanguage.SPARQL, deleteQuery);
update.execute();
} finally {
closeQuietly(deleteConn);
}
}
log.info("File loading test finished.");
}
Aggregations