### Question:
InternalSubchannel implements InternalInstrumented<ChannelStats> { void shutdownNow(Status reason) { shutdown(reason); Collection<ManagedClientTransport> transportsCopy; try { synchronized (lock) { transportsCopy = new ArrayList<ManagedClientTransport>(transports); } } finally { syncContext.drain(); } for (ManagedClientTransport transport : transportsCopy) { transport.shutdownNow(reason); } } InternalSubchannel(List<EquivalentAddressGroup> addressGroups, String authority, String userAgent,
      BackoffPolicy.Provider backoffPolicyProvider,
      ClientTransportFactory transportFactory, ScheduledExecutorService scheduledExecutor,
      Supplier<Stopwatch> stopwatchSupplier, SynchronizationContext syncContext, Callback callback,
      InternalChannelz channelz, CallTracer callsTracer, ChannelTracer channelTracer,
      InternalLogId logId, TimeProvider timeProvider); void updateAddresses(List<EquivalentAddressGroup> newAddressGroups); void shutdown(Status reason); @Override String toString(); @Override InternalLogId getLogId(); @Override ListenableFuture<ChannelStats> getStats();  }### Answer:
@Test public void shutdownNow() throws Exception { SocketAddress addr = mock(SocketAddress.class); createInternalSubchannel(addr); internalSubchannel.obtainActiveTransport(); MockClientTransportInfo t1 = transports.poll(); t1.listener.transportReady(); assertExactCallbackInvokes("onStateChange:CONNECTING", "onStateChange:READY"); t1.listener.transportShutdown(Status.UNAVAILABLE); assertExactCallbackInvokes("onStateChange:IDLE"); internalSubchannel.obtainActiveTransport(); assertExactCallbackInvokes("onStateChange:CONNECTING"); MockClientTransportInfo t2 = transports.poll(); Status status = Status.UNAVAILABLE.withDescription("Requested"); internalSubchannel.shutdownNow(status); verify(t1.transport).shutdownNow(same(status)); verify(t2.transport).shutdownNow(same(status)); assertExactCallbackInvokes("onStateChange:SHUTDOWN"); }