MountTableResolver implements FileSubclusterResolver, StateStoreCache { public List<MountTable> getMounts(final String path) throws IOException { verifyMountTable(); return getTreeValues(RouterAdmin.normalizeFileSystemPath(path), false); } @VisibleForTesting  MountTableResolver(Configuration conf);  MountTableResolver(Configuration conf, Router routerService);  MountTableResolver(Configuration conf, StateStoreService store);  MountTableResolver(Configuration conf, Router routerService,
      StateStoreService store); void addEntry(final MountTable entry); void removeEntry(final String srcPath); @VisibleForTesting void refreshEntries(final Collection<MountTable> entries); @Override boolean loadCache(boolean force); void clear(); @Override PathLocation getDestinationForPath(final String path); PathLocation lookupLocation(final String str); MountTable getMountPoint(final String path); @Override List<String> getMountPoints(final String str); List<MountTable> getMounts(final String path); @Override String toString(); @Override String getDefaultNamespace(); @VisibleForTesting String getDefaultNameService(); @VisibleForTesting void setDefaultNameService(String defaultNameService); @VisibleForTesting boolean isDefaultNSEnable(); @VisibleForTesting void setDefaultNSEnable(boolean defaultNSRWEnable); @VisibleForTesting void setDisabled(boolean disable);  }
@Test public void testGetMounts() throws IOException { List<MountTable> records = mountTable.getMounts("/"); assertEquals(10, records.size()); compareRecords(records, new String[] {"/", "/tmp", "/user", "/usr/bin", "user/a", "/user/a/demo/a", "/user/a/demo/b", "/user/b/file1.txt", "readonly", "multi"}); records = mountTable.getMounts("/user"); assertEquals(5, records.size()); compareRecords(records, new String[] {"/user", "/user/a/demo/a", "/user/a/demo/b", "user/a", "/user/b/file1.txt"}); records = mountTable.getMounts("/user/a"); assertEquals(3, records.size()); compareRecords(records, new String[] {"/user/a/demo/a", "/user/a/demo/b", "/user/a"}); records = mountTable.getMounts("/tmp"); assertEquals(1, records.size()); compareRecords(records, new String[] {"/tmp"}); records = mountTable.getMounts("/readonly"); assertEquals(1, records.size()); compareRecords(records, new String[] {"/readonly"}); assertTrue(records.get(0).isReadOnly()); records = mountTable.getMounts("/multi"); assertEquals(1, records.size()); compareRecords(records, new String[] {"/multi"}); }
@Test public void testGetMountsOfConsecutiveSlashes() throws IOException { List<MountTable> records = mountTable.getMounts(" assertEquals(10, records.size()); compareRecords(records, new String[] {"/", "/tmp", "/user", "/usr/bin", "user/a", "/user/a/demo/a", "/user/a/demo/b", "/user/b/file1.txt", "readonly", "multi"}); records = mountTable.getMounts("/user assertEquals(5, records.size()); compareRecords(records, new String[] {"/user", "/user/a/demo/a", "/user/a/demo/b", "user/a", "/user/b/file1.txt"}); records = mountTable.getMounts(" assertEquals(3, records.size()); compareRecords(records, new String[] {"/user/a/demo/a", "/user/a/demo/b", "/user/a"}); }