@Test
  public void testPersistingSnapshotsForNamespaces() throws Exception {
    TableName tn1 = TableName.valueOf("ns1:tn1");
    TableName tn2 = TableName.valueOf("ns1:tn2");
    TableName tn3 = TableName.valueOf("ns2:tn1");
    TableName tn4 = TableName.valueOf("ns2:tn2");
    TableName tn5 = TableName.valueOf("tn1");
    // Shim in a custom factory to avoid computing snapshot sizes.
    FileArchiverNotifierFactory test = new FileArchiverNotifierFactory() {
      Map<TableName, Long> tableToSize =
        ImmutableMap.of(tn1, 1024L, tn2, 1024L, tn3, 512L, tn4, 1024L, tn5, 3072L);

      @Override
      public FileArchiverNotifier get(Connection conn, Configuration conf, FileSystem fs,
        TableName tn) {
        return new FileArchiverNotifier() {
          @Override
          public void addArchivedFiles(Set<Entry<String, Long>> fileSizes) throws IOException {
          }

          @Override
          public long computeAndStoreSnapshotSizes(Collection<String> currentSnapshots)
            throws IOException {
            return tableToSize.get(tn);
          }
        };
      }
    };
    try {
      FileArchiverNotifierFactoryImpl.setInstance(test);

      Multimap<TableName, String> snapshotsToCompute = HashMultimap.create();
      snapshotsToCompute.put(tn1, "");
      snapshotsToCompute.put(tn2, "");
      snapshotsToCompute.put(tn3, "");
      snapshotsToCompute.put(tn4, "");
      snapshotsToCompute.put(tn5, "");
      Map<String, Long> nsSizes = testChore.computeSnapshotSizes(snapshotsToCompute);
      assertEquals(3, nsSizes.size());
      assertEquals(2048L, (long) nsSizes.get("ns1"));
      assertEquals(1536L, (long) nsSizes.get("ns2"));
      assertEquals(3072L, (long) nsSizes.get(NamespaceDescriptor.DEFAULT_NAMESPACE_NAME_STR));
    } finally {
      FileArchiverNotifierFactoryImpl.reset();
    }
  }
Test class for the {@link SnapshotQuotaObserverChore}.
hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSnapshotQuotaObserverChore.java