CommandLineIO { public List<String> getOutputStringList() { String outputString = outputStream.toString(); String[] outputStringArray = outputString.split("\n"); return Arrays.asList(outputStringArray); } CommandLineIO(ByteArrayOutputStream outputStream, ByteArrayOutputStream errorStream);  CommandLineIO(ByteArrayOutputStream outputStream, ByteArrayOutputStream errorStream, CommandLineResultHandler resultHandler); List<String> getOutputStringList(); List<String> getErrorStringList(); ByteArrayOutputStream getOutputStream(); ByteArrayOutputStream getErrorStream(); CommandLineResultHandler getResultHandler();  }
@Test public void canGetOutputStringList() throws Exception { when(mockOutputStream.toString()).thenReturn("Successfully added user test111 to LDAP\n" + "Successfully set password for user test111"); commandLineIO = new CommandLineIO(mockOutputStream, mockErrorStream); List<String> outputStringList = commandLineIO.getOutputStringList(); assertThat(outputStringList.size(), equalTo(2)); assertThat(outputStringList.get(0), equalTo("Successfully added user test111 to LDAP")); assertThat(outputStringList.get(1), equalTo("Successfully set password for user test111")); }