Bootstrap extends MockTCPServerPool { public void startup() throws ConfigurationException, InterruptedException { final Set<Integer> ports = getConfigurationSettings().getPorts(); for (Iterator<Integer> iterator = ports.iterator(); iterator.hasNext();) { final Integer port = iterator.next(); getServerPool().add(new MockTCPServer(port)); } super.start(); }  void startup(); @Override void shutdown(); MockTCPServerPool getServerPool();  }
@Test(timeout = TestConstants.TEST_TIMEOUT_5_MINUTE) public void startup() throws ConfigurationException, InterruptedException, IOException { try (final Bootstrap bootstrap = new Bootstrap();) { bootstrap.startup(); final List<String> expectedMessages = new ArrayList<>(Arrays.asList(StringEscapeUtils.unescapeJava(TestConstants.MACHINE_A_RESPONSE_MESSAGE), StringEscapeUtils.unescapeJava(TestConstants.MACHINE_B_RESPONSE_MESSAGE))); testResponses(bootstrap.getServerPool().get(TestConstants.MOCK_SERVER_PORT_1234), TestConstants.MOCK_SERVER_PORT_2345, TestConstants.INCOMING_MESSAGE_ONE + TestConstants.DEFAULT_TERMINATOR, expectedMessages, TestConstants.SERVER_TIMEOUT, TestConstants.ONE_TENTH_OF_A_SECOND); checkLogMonitorForUnexpectedMessages(); testResponses(bootstrap.getServerPool().get(TestConstants.MOCK_SERVER_PORT_6789), TestConstants.MOCK_SERVER_PORT_5678, TestConstants.WELLFORMED_XML_WITH_VALID_TERMINATOR, expectedMessages, TestConstants.SERVER_TIMEOUT, TestConstants.ONE_TENTH_OF_A_SECOND); checkLogMonitorForUnexpectedMessages(); bootstrap.shutdown(); } }