@Test(expected = AbortedScanException.class)
public void testBuildWithPreInstallHooks_throws() throws Exception {

    final File badInstallHookPackage = TestPackageUtil.prepareTestPackageFromFolder("bad-install-hook.zip",
            new File("src/test/resources/package_with_bad_installhook"));
    final File testPackage = TestPackageUtil.prepareTestPackage("tmp_foo_bar.zip");
    final InstallHookProcessor processor = mock(InstallHookProcessor.class);
    doThrow(new PackageException("throws")).when(processor).registerHooks(any(Archive.class), any(ClassLoader.class));
    builder().withEnablePreInstallHooks(true)
            .withPreInstallUrl(testPackage.toURI().toURL(), badInstallHookPackage.toURI().toURL())
            .withInstallHookProcessorFactory(() -> processor)
            .build().initAndInspect(session -> {
        assertTrue("path should exist", session.nodeExists("/tmp/foo/bar"));
    });
}