private void assertEncodingDetection(String encoding, String input, String expectedContent)
throws Exception {
DocumentSource fileDocumentSource = getDocumentSourceFromResource(input);
Any23 any23;
RepositoryConnection conn = null;
RepositoryWriter repositoryWriter = null;
any23 = new Any23();
Repository store = new SailRepository(new MemoryStore());
store.initialize();
try
{
conn = store.getConnection();
repositoryWriter = new RepositoryWriter(conn);
Assert.assertTrue( any23.extract(fileDocumentSource, repositoryWriter, encoding).hasMatchingExtractors() );
RepositoryResult<Statement> statements = conn.getStatements(null, vDCTERMS.title, null, false);
try {
while (statements.hasNext()) {
Statement statement = statements.next();
printStatement(statement);
Assert.assertTrue(statement.getObject().stringValue().contains(expectedContent));
}
} finally {
statements.close();
}
}
finally {
if(conn != null) {
conn.close();
}
if(repositoryWriter != null) {
repositoryWriter.close();
}
}
fileDocumentSource = null;
any23 = null;
}