### Question:
ClientSender extends StreamSender implements BlockingSender { public Message blockingSend(Message message) throws CommunicationException { final MessageRequiringResponse messageRequiringResponse = new MessageRequiringResponse(message); final Message result; synchronized (m_socketWrapper) { send(messageRequiringResponse); final Receiver receiver = new StreamReceiver(m_socketWrapper.getInputStream()); result = receiver.waitForMessage(); } if (result == null) { throw new CommunicationException("Shut down"); } else if (result instanceof NoResponseMessage) { throw new NoResponseException("Server did not respond"); } return result; } private  ClientSender(SocketWrapper socketWrapper); static ClientSender connect(Connector connector, Address address); static ClientSender connect(ClientReceiver clientReceiver); @Override void shutdown(); Message blockingSend(Message message); void sendKeepAlive();  }### Answer:
@Test public void testBlockingSend() throws Exception { final SocketAcceptorThread socketAcceptor = SocketAcceptorThread.create(); final Connector connector = new Connector(socketAcceptor.getHostName(), socketAcceptor.getPort(), ConnectionType.AGENT); final BlockingSender clientSender = ClientSender.connect(connector, null); socketAcceptor.join(); final Socket acceptedSocket = socketAcceptor.getAcceptedSocket(); final InputStream socketInput = acceptedSocket.getInputStream(); final OutputStream socketOutput = acceptedSocket.getOutputStream(); assertEquals(ConnectionType.AGENT, Connector.read(socketInput).getConnectionType()); final SimpleMessage message1 = new SimpleMessage(); final ReceiveOneMessageAndReply receiver1 = new ReceiveOneMessageAndReply(socketInput, socketOutput); receiver1.start(); final Object received1 = clientSender.blockingSend(message1); assertEquals(message1, received1); receiver1.join(); assertNull(receiver1.getException()); final NoResponseMessage message2 = new NoResponseMessage(); final ReceiveOneMessageAndReply receiver2 = new ReceiveOneMessageAndReply(socketInput, socketOutput); receiver2.start(); try { clientSender.blockingSend(message2); fail("Expected NoResponseException"); } catch (NoResponseException e) { } receiver2.join(); assertNull(receiver2.getException()); socketAcceptor.close(); }