DnsNameResolver extends NameResolver { @GuardedBy("this") private void resolve() { if (resolving || shutdown) { return; } executor.execute(resolutionRunnable); } DnsNameResolver(@Nullable String nsAuthority, String name, Attributes params,
      Resource<ScheduledExecutorService> timerServiceResource,
      Resource<ExecutorService> executorResource); @Override final String getServiceAuthority(); @Override final synchronized void start(Listener listener); @Override final synchronized void refresh(); @Override final synchronized void shutdown();  }
@Test public void resolve() throws Exception { InetAddress[] answer1 = createAddressList(2); InetAddress[] answer2 = createAddressList(1); String name = "foo.googleapis.com"; MockResolver resolver = new MockResolver(name, 81, answer1, answer2); resolver.start(mockListener); assertEquals(1, fakeExecutor.runDueTasks()); verify(mockListener).onUpdate(resultCaptor.capture(), any(Attributes.class)); assertEquals(name, resolver.invocations.poll()); assertAnswerMatches(answer1, 81, resultCaptor.getValue()); assertEquals(0, fakeClock.numPendingTasks()); resolver.refresh(); assertEquals(1, fakeExecutor.runDueTasks()); verify(mockListener, times(2)).onUpdate(resultCaptor.capture(), any(Attributes.class)); assertEquals(name, resolver.invocations.poll()); assertAnswerMatches(answer2, 81, resultCaptor.getValue()); assertEquals(0, fakeClock.numPendingTasks()); resolver.shutdown(); }