JcrPackageManagerImpl extends PackageManagerImpl implements JcrPackageManager { protected Node mkdir(String path, boolean autoSave) throws RepositoryException { return registry.mkdir(path, autoSave); } JcrPackageManagerImpl(@NotNull Session session, @Nullable String[] roots);  JcrPackageManagerImpl(@NotNull Session session, @Nullable String[] roots, @Nullable String[] authIdsForHookExecution, @Nullable String[] authIdsForRootInstallation); protected  JcrPackageManagerImpl(JcrPackageRegistry registry); PackageRegistry getRegistry(); JcrPackageRegistry getInternalRegistry(); @Override JcrPackage open(PackageId id); @Override JcrPackage open(Node node); @Override JcrPackage open(Node node, boolean allowInvalid); @Override PackageId resolve(Dependency dependency, boolean onlyInstalled); @Override PackageId[] usage(PackageId id); @Override JcrPackage upload(InputStream in, boolean replace); @Override JcrPackage upload(InputStream in, boolean replace, boolean strict); @NotNull @Override PackageId[] extract(@NotNull Archive archive, @NotNull ImportOptions options, boolean replace); @Override JcrPackage upload(File file, boolean isTmpFile, boolean replace, String nameHint); @Override JcrPackage upload(File file, boolean isTmpFile, boolean replace, String nameHint, boolean strict); @Override JcrPackage create(Node folder, String name); @Override JcrPackage create(String group, String name); @Override JcrPackage create(String group, String name, String version); @Override void remove(JcrPackage pack); @Override JcrPackage rename(JcrPackage pack, String group, String name); @Override JcrPackage rename(JcrPackage pack, String group, String name, String version); @Override void assemble(JcrPackage pack, ProgressTrackerListener listener); @Override void assemble(Node packNode, JcrPackageDefinition definition,
                         ProgressTrackerListener listener); @Override void assemble(JcrPackageDefinition definition,
                         ProgressTrackerListener listener, OutputStream out); @Override void rewrap(JcrPackage pack, ProgressTrackerListener listener); @Override Node getPackageRoot(); @Override Node getPackageRoot(boolean noCreate); @Override List<JcrPackage> listPackages(); @Override List<JcrPackage> listPackages(WorkspaceFilter filter); @Override List<JcrPackage> listPackages(String group, boolean built); @Override void setDispatcher(@Nullable PackageEventDispatcher dispatcher); final static String ARCHIVE_PACKAGE_ROOT_PATH; }
@Test public void testMkdDirWithUnauthorizedSession() throws Exception { Session session = mock(Session.class); when(session.nodeExists(anyString())).thenReturn(false); when(session.getWorkspace()).thenReturn(admin.getWorkspace()); JcrPackageManagerImpl jcrPackageManager = new JcrPackageManagerImpl(session, new String[0]); String path = "/etc/packages"; try { jcrPackageManager.mkdir(path, true); fail("this should have thrown RepositoryException as the session always tells nodes don't exist"); } catch (RepositoryException e) { } }
@Test @Ignore("unstable results in maven") public void testMkDirWithAnonymousSession() throws Exception { Session session = repository.login(new GuestCredentials()); JcrPackageManagerImpl jcrPackageManager = new JcrPackageManagerImpl(session, new String[0]); jcrPackageManager.mkdir("/something/that/is/not/going/to/be/found/anywhere/in/this/repository/even/if/searching/in/very/long/paths/like/this", false); jcrPackageManager.mkdir("/something/that/is/not/going/to/be/found/anywhere/in/this/repository/even/if/searching/in/very/long/paths/like/this", false); jcrPackageManager.mkdir("/something/that/is/not/going/to/be/found/anywhere/in/this/repository/even/if/searching/in/very/long/paths/like/this", false); }
@Test public void mkdDirStressTest() throws Exception { JcrPackageManagerImpl jcrPackageManager = new JcrPackageManagerImpl(admin, new String[0]); String path = admin.getRootNode().getPath(); while (path != null) { jcrPackageManager.mkdir(path, true); jcrPackageManager.mkdir(path, false); path = getNextPath(path); } }