@Test
public void openDocumentWrongPassword() throws TaskIOException, IOException {

    try {
        File tmp = IOUtils.createTemporaryBufferWithName("dumbo.pdf");
        OutputStream out = new FileOutputStream(tmp);
        InputStream in = getClass().getClassLoader().getResourceAsStream("pdf/encrypted_AES128_user_pwd.pdf");
        try {
            org.apache.commons.io.IOUtils.copy(in, out);
        } finally {
            org.sejda.commons.util.IOUtils.closeQuietly(out);
            org.sejda.commons.util.IOUtils.closeQuietly(in);
        }
        new DefaultPdfSourceOpener().open(PdfFileSource.newInstanceWithPassword(tmp, "my source"));
        fail("Exception expected");
    } catch (TaskWrongPasswordException e) {
        assertEquals("Unable to open 'dumbo.pdf' due to a wrong password.", e.getMessage());
    }
}