### Question:
FederatedZKLogMetadataStore extends NamespaceWatcher implements LogMetadataStore, Watcher, Runnable, FutureEventListener<Set<URI>> { @Override public void registerNamespaceListener(NamespaceListener listener) { registerListener(listener); } FederatedZKLogMetadataStore(
            DistributedLogConfiguration conf,
            URI namespace,
            ZooKeeperClient zkc,
            OrderedScheduler scheduler); static void createFederatedNamespace(URI namespace, ZooKeeperClient zkc); @Override void run(); @Override void onSuccess(Set<URI> uris); @Override void onFailure(Throwable cause); @Override void process(WatchedEvent watchedEvent); @Override CompletableFuture<URI> createLog(final String logName); @Override CompletableFuture<Optional<URI>> getLogLocation(final String logName); @Override CompletableFuture<Iterator<String>> getLogs(String logNamePrefix); @Override void registerNamespaceListener(NamespaceListener listener);  }### Answer:
@Test(timeout = 60000) public void testNamespaceListener() throws Exception { int numLogs = 3 * maxLogsPerSubnamespace; TestNamespaceListenerWithExpectedSize listener = new TestNamespaceListenerWithExpectedSize(numLogs); metadataStore.registerNamespaceListener(listener); Set<String> expectedLogs = createLogs(numLogs, "test-namespace-listener"); listener.waitForDone(); Set<String> receivedLogs = listener.getResult(); assertEquals(numLogs, receivedLogs.size()); assertTrue(Sets.difference(expectedLogs, receivedLogs).isEmpty()); Random r = new Random(System.currentTimeMillis()); int logId = r.nextInt(numLogs); String logName = "test-namespace-listener" + logId; TestNamespaceListener deleteListener = new TestNamespaceListener(); metadataStore.registerNamespaceListener(deleteListener); deleteLog(logName); deleteListener.waitForDone(); Set<String> logsAfterDeleted = Sets.newTreeSet(Lists.newArrayList(deleteListener.getResult())); assertEquals(numLogs - 1, logsAfterDeleted.size()); expectedLogs.remove(logName); assertTrue(Sets.difference(expectedLogs, receivedLogs).isEmpty()); }