@Test
public void existingOutputPolicyRENAME_exception() throws IOException {

    Map<String, File> files = new HashMap<String, File>();
    files.put("existing.pdf", folder.newFile());
    File outFile = outputFolder.newFile("existing.pdf");
    for (int i = 1; i <= 100; i++) {
        outputFolder.newFile(String.format("existing(%d).pdf", i));
    }
    try {
        OutputWriterHelper.moveToFile(files, outFile, ExistingOutputPolicy.RENAME, context);
        fail("Exception expected, about the fact that a new filename that doesn't exist could not be generated");
    } catch (IOException e) {
        assertTrue("Different exception expected, got: " + e.getMessage(),
                e.getMessage().startsWith("Unable to generate a new filename that does not exist"));
    }
}