@Test public void testBuildWithInstallClassLoader() throws Exception { final File testPackage = TestPackageUtil.prepareTestPackage("tmp_foo_bar.zip"); final ClassLoader hookClassLoader = new URLClassLoader(new URL[]{testPackage.toURI().toURL()}, null); final CompletableFuture<Boolean> latch = new CompletableFuture<>(); final InstallHookProcessor processor = mock(InstallHookProcessor.class); when(processor.execute(any(InstallContext.class))).thenReturn(true); doAnswer(call -> latch.complete(hookClassLoader == call.getArgument(1, ClassLoader.class))) .when(processor) .registerHooks(any(Archive.class), any(ClassLoader.class)); builder().withEnablePreInstallHooks(true) .withPreInstallUrl(testPackage.toURI().toURL()) .withInstallHookProcessorFactory(() -> processor) .withInstallHookClassLoader(hookClassLoader) .build().initAndInspect(session -> { assertTrue("path should exist", session.nodeExists("/tmp/foo/bar")); assertTrue("hook processor was called with specific class loader", latch.getNow(false)); }); }
@SuppressWarnings("WeakerAccess") public <E extends Throwable> void initAndInspect(final InspectBody<E> inspectBody) throws AbortedScanException, RepositoryException, E { adminInitAndInspect(admin -> { final Session inspectSession = Util.wrapSessionReadOnly(admin); inspectBody.tryAccept(inspectSession); }); }
OakMachine { @SuppressWarnings("WeakerAccess") public <E extends Throwable> void initAndInspect(final InspectBody<E> inspectBody) throws AbortedScanException, RepositoryException, E { adminInitAndInspect(admin -> { final Session inspectSession = Util.wrapSessionReadOnly(admin); inspectBody.tryAccept(inspectSession); }); } }
OakMachine { @SuppressWarnings("WeakerAccess") public <E extends Throwable> void initAndInspect(final InspectBody<E> inspectBody) throws AbortedScanException, RepositoryException, E { adminInitAndInspect(admin -> { final Session inspectSession = Util.wrapSessionReadOnly(admin); inspectBody.tryAccept(inspectSession); }); } private  OakMachine(final Packaging packagingService,
                       final List<ProgressCheck> progressChecks,
                       final ErrorListener errorListener,
                       final List<URL> preInstallUrls,
                       final List<InitStage> initStages,
                       final JcrCustomizer jcrCustomizer,
                       final InstallHookProcessorFactory installHookProcessorFactory,
                       final ClassLoader installHookClassLoader,
                       final boolean enablePreInstallHooks,
                       final InstallHookPolicy scanInstallHookPolicy,
                       final Supplier<NodeStore> nodeStoreSupplier,
                       final SubpackageSilencer subpackageSilencer,
                       final RepoInitProcessor repoInitProcessor,
                       final SlingSimulatorBackend slingSimulator,
                       final Set<String> runModes); }
OakMachine { @SuppressWarnings("WeakerAccess") public <E extends Throwable> void initAndInspect(final InspectBody<E> inspectBody) throws AbortedScanException, RepositoryException, E { adminInitAndInspect(admin -> { final Session inspectSession = Util.wrapSessionReadOnly(admin); inspectBody.tryAccept(inspectSession); }); } private  OakMachine(final Packaging packagingService,
                       final List<ProgressCheck> progressChecks,
                       final ErrorListener errorListener,
                       final List<URL> preInstallUrls,
                       final List<InitStage> initStages,
                       final JcrCustomizer jcrCustomizer,
                       final InstallHookProcessorFactory installHookProcessorFactory,
                       final ClassLoader installHookClassLoader,
                       final boolean enablePreInstallHooks,
                       final InstallHookPolicy scanInstallHookPolicy,
                       final Supplier<NodeStore> nodeStoreSupplier,
                       final SubpackageSilencer subpackageSilencer,
                       final RepoInitProcessor repoInitProcessor,
                       final SlingSimulatorBackend slingSimulator,
                       final Set<String> runModes); List<ProgressCheck> getProgressChecks(); ErrorListener getErrorListener(); @Deprecated List<File> getPreInstallFiles(); List<URL> getPreInstallUrls(); @SuppressWarnings("WeakerAccess") void initAndInspect(final InspectBody<E> inspectBody); void adminInitAndInspect(final InspectBody<E> inspectBody); List<CheckReport> scanPackage(final @NotNull File... file); List<CheckReport> scanPackages(final List<File> files); static Packaging newOakpalPackagingService(); static Packaging newOakpalPackagingService(final @NotNull ClassLoader classLoader); }
OakMachine { @SuppressWarnings("WeakerAccess") public <E extends Throwable> void initAndInspect(final InspectBody<E> inspectBody) throws AbortedScanException, RepositoryException, E { adminInitAndInspect(admin -> { final Session inspectSession = Util.wrapSessionReadOnly(admin); inspectBody.tryAccept(inspectSession); }); } private  OakMachine(final Packaging packagingService,
                       final List<ProgressCheck> progressChecks,
                       final ErrorListener errorListener,
                       final List<URL> preInstallUrls,
                       final List<InitStage> initStages,
                       final JcrCustomizer jcrCustomizer,
                       final InstallHookProcessorFactory installHookProcessorFactory,
                       final ClassLoader installHookClassLoader,
                       final boolean enablePreInstallHooks,
                       final InstallHookPolicy scanInstallHookPolicy,
                       final Supplier<NodeStore> nodeStoreSupplier,
                       final SubpackageSilencer subpackageSilencer,
                       final RepoInitProcessor repoInitProcessor,
                       final SlingSimulatorBackend slingSimulator,
                       final Set<String> runModes); List<ProgressCheck> getProgressChecks(); ErrorListener getErrorListener(); @Deprecated List<File> getPreInstallFiles(); List<URL> getPreInstallUrls(); @SuppressWarnings("WeakerAccess") void initAndInspect(final InspectBody<E> inspectBody); void adminInitAndInspect(final InspectBody<E> inspectBody); List<CheckReport> scanPackage(final @NotNull File... file); List<CheckReport> scanPackages(final List<File> files); static Packaging newOakpalPackagingService(); static Packaging newOakpalPackagingService(final @NotNull ClassLoader classLoader); static final String NS_URI_OAKPAL; static final String NS_PREFIX_OAKPAL; static final String LN_UNDECLARED; static final String NT_UNDECLARED; }