### Question:
Acceptor { public Exception getPendingException() { synchronized (m_socketSets) { if (m_isShutdown) { return null; } } try { return m_exceptionQueue.take(); } catch (InterruptedException e) { throw new UncheckedInterruptedException(e); } } Acceptor(String addressString,
                  int port,
                  int numberOfThreads,
                  TimeAuthority timeAuthority); void shutdown(); int getPort(); Exception getPendingException(); int getNumberOfConnections(); void addListener(ConnectionType connectionType, Listener listener);  }### Answer:
@Test public void testGetPendingException() throws Exception { final Acceptor acceptor = createAcceptor(3); assertNull(acceptor.peekPendingException()); final Socket socket = new Socket("localhost", acceptor.getPort()); for (int i = 0; i < 10; ++i) { socket.getOutputStream().write(99); } socket.getOutputStream().flush(); final Socket socket2 = new Socket("localhost", acceptor.getPort()); for (int i = 0; i < 10; ++i) { socket2.getOutputStream().write(99); } socket2.getOutputStream().flush(); assertTrue(acceptor.getPendingException() instanceof CommunicationException); assertTrue(acceptor.getPendingException() instanceof CommunicationException); assertNull(acceptor.peekPendingException()); acceptor.shutdown(); assertNull(acceptor.getPendingException()); }
@Test public void testGetPendingExceptionInterrupted() throws Exception { final Acceptor acceptor = createAcceptor(3); Thread.currentThread().interrupt(); try { acceptor.getPendingException(); fail("Expected UncheckedInterruptedException"); } catch (UncheckedInterruptedException e) { } }