MountInfo implements Mount { @Override public boolean isMounted(String path) { if (path.contains(pathFragmentName)) { String parent = path.substring(0, path.indexOf(pathFragmentName)); parent = parent.substring(0, parent.lastIndexOf('/')); if (isSupportFragment(parent)) { return true; } } path = SANITIZE_PATH.apply(path); String previousPath = includedPaths.floor(path); return previousPath != null && (previousPath.equals(path) || isAncestor(previousPath, path)); } MountInfo(String name, boolean readOnly, List<String> pathsSupportingFragments,
              List<String> includedPaths); @Override boolean isUnder(String path); @Override boolean isDirectlyUnder(String path); @Override boolean isMounted(String path); @Override String getName(); @Override boolean isReadOnly(); @Override boolean isDefault(); @Override boolean isSupportFragment(String path); @Override boolean isSupportFragmentUnder(String path); @Override String getPathFragmentName(); Set<String> getPathsSupportingFragments(); Set<String> getIncludedPaths(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj);  }
@Test public void testIsMounted() throws Exception{ MountInfo md = new MountInfo("foo", false, of("/x/y"), of("/a", "/b")); assertTrue(md.isMounted("/a")); assertTrue(md.isMounted("/b")); assertTrue(md.isMounted("/b/c/d")); assertTrue("dynamic mount path not recognized", md.isMounted("/x/y/oak:mount-foo/a")); assertTrue("dynamic mount path not recognized", md.isMounted("/x/y/z/oak:mount-foo/a")); assertFalse(md.isMounted("/x/y")); assertFalse(md.isMounted("/x/y/foo")); assertFalse(md.isMounted("/d/c/oak:mount-foo/a")); }
@Test public void testIsMountedWithFragments() { MountInfo md = new MountInfo("foo", false, of("/apps", "/libs/*/site", "/content/*$", "/var$"), Collections.emptyList()); assertFalse(md.isMounted("/oak:mount-foo")); assertTrue(md.isMounted("/apps/oak:mount-foo")); assertTrue(md.isMounted("/apps/oak:mount-foo/xyz")); assertTrue(md.isMounted("/apps/acme/oak:mount-foo")); assertTrue(md.isMounted("/apps/acme/oak:mount-foo/xyz")); assertFalse(md.isMounted("/libs/oak:mount-foo")); assertFalse(md.isMounted("/libs/acme/oak:mount-foo")); assertTrue(md.isMounted("/libs/acme/site/oak:mount-foo")); assertTrue(md.isMounted("/libs/acme/site/oak:mount-foo/xyz")); assertTrue(md.isMounted("/libs/acme/site/abc/oak:mount-foo")); assertFalse(md.isMounted("/oak:mount-foo")); assertFalse(md.isMounted("/content/oak:mount-foo")); assertTrue(md.isMounted("/content/site/oak:mount-foo")); assertTrue(md.isMounted("/content/site/oak:mount-foo/xyz")); assertFalse(md.isMounted("/content/site/abc/oak:mount-foo")); assertFalse(md.isMounted("/content/site/abc/oak:mount-foo/xyz")); assertTrue(md.isMounted("/var/oak:mount-foo")); assertFalse(md.isMounted("/var/abc/oak:mount-foo")); }