### Question:
Connection { public void shutdown() { messageIO.closeInputStream(); messageIO.closeOutputStream(); } protected  Connection(MessageIO streams); static Message generatePublicKeyMessage(Key publicKey); static KeyPair generateRSAKeyPair(); void start(); void setRSAKeyPair(KeyPair rsaKeyPair); MessageIO getMessageIO(); PingTracker getPingTracker(); ExecutableMessageQueue getExecutableMessageQueue(); void shutdown(); String getName(); void setName(String name); @SuppressWarnings("ReturnOfCollectionOrArrayField") Map<InetAddress, Key> getVerifiedKeys();  }### Answer:
@Test(expectedExceptions = MessageQueueException.class) public void testShutDown() throws Exception { DataInputStreamMock dataInputStreamMock = new DataInputStreamMock(); InputStream in = dataInputStreamMock.getIn(); dataInputStreamMock.mockReadShort((short) INVALID_MESSAGE_ID); ByteArrayOutputStream bos = new ByteArrayOutputStream(); MessageInputStream messageInputStream = new MessageInputStream(in); MessageOutputStream messageOutputStream = new MessageOutputStream(bos); MessageIO messageIO = new MessageIO(messageInputStream, messageOutputStream); Connection connection = new Connection(messageIO); connection.shutdown(); Message msg = MESSAGE_REGISTRY.createMessage("InvalidMessage"); msg.setArgument("messageName", "FooBar"); msg.setArgument("messageID", (short) INVALID_MESSAGE_ID); connection.getMessageIO().queueOutgoingMessage(msg); try { connection.getMessageIO().writeAllMessages(); } catch (IOException e) { connection.shutdown(); } }