OakMachine { public <E extends Throwable> void adminInitAndInspect(final InspectBody<E> inspectBody) throws AbortedScanException, RepositoryException, E { Session admin = null; Repository scanRepo = null; try { scanRepo = initRepository(); admin = loginAdmin(scanRepo); addOakpalTypes(admin); final JcrPackageManager manager = packagingService.getPackageManager(admin); for (InitStage initStage : this.initStages) { initStage.initSession(admin, getErrorListener(), repoInitProcessor); } initSlingSimulator(admin, manager, errorListener); for (final URL url : preInstallUrls) { processPackageUrl(admin, manager, true, url); } inspectBody.tryAccept(admin); } finally { if (admin != null) { admin.logout(); } shutdownRepository(scanRepo); } } 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; }
@Test public void testFileBlobMemoryNodeStore() throws Exception { final File blobStoreFile = new File(testOutDir, "testFileBlobMemoryNodeStore/datastore"); if (blobStoreFile.isDirectory()) { FileUtils.deleteDirectory(blobStoreFile); } final OakMachine.Builder machineBuilder = builder().withNodeStoreSupplier(() -> new FileBlobMemoryNodeStore(blobStoreFile.getAbsolutePath())); machineBuilder.build().adminInitAndInspect(session -> { final Binary binary = alphaFill(session, 4093); Node fooNode = session.getRootNode().addNode("foo", "nt:unstructured"); fooNode.setProperty("data", binary); session.save(); assertTrue("blob is retrievable", fooNode.getProperty("data").getString().startsWith("abcdefg")); }); final File[] inlineChildren = blobStoreFile.listFiles(); assertNotNull("should have non-null inlineChildren", inlineChildren); assertEquals("inline children is empty <4k", 0, inlineChildren.length); machineBuilder.build().adminInitAndInspect(session -> { final Binary binary = alphaFill(session, 8192); assertFalse("/foo should not exist", session.nodeExists("/foo")); Node fooNode = session.getRootNode().addNode("foo", "nt:unstructured"); fooNode.setProperty("data", binary); session.save(); assertTrue("blob is retrievable", fooNode.getProperty("data").getString().startsWith("abcdefg")); }); final File[] blobChildren = blobStoreFile.listFiles(); assertNotNull("should have non-null blobChildren", blobChildren); assertEquals("blobChildren is not empty @>4k", 1, blobChildren.length); }